<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增巡检点')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-dian-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">巡检点名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">位置：</label>
                <div class="col-sm-8">
                    <input name="position" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">经度：</label>
                <div class="col-sm-8">
                    <input name="along" id="along" readonly="readonly"  style="width:430px;display: inline" class="form-control" type="text" required>
                    <span style="margin-left: 30px" onclick="addFullWei()" class="fa fa-map-pin"></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">纬度：</label>
                <div class="col-sm-8">
                    <input name="latitude" id="latitude" readonly="readonly" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">备注：</label>
                <div class="col-sm-8">
                    <input name="remark"  class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "inspection/dian"
        $("#form-dian-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-dian-add').serialize());
            }
        }
        function addFullWei(){
            var yi1=($("#along").val()==null || $("#along").val()=="" )?"1":$("#along").val();
            var er1=($("#latitude").val()==null || $("#latitude").val()=="")?"1":$("#latitude").val();
            var index = layer.open({
                type: 2,
                area: [800+ 'px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "添加巡检点",
                content: "/common/dian?along="+yi1+"&latitude="+er1,
                btn: ['确定', '关闭'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: doSubmit,

                cancel: function(index) {
                    return true;
                },
                callBack: doSubmit
            });
            layer.full(index);
        }


        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var yi=body.find('#along').val();
            var er=body.find('#latitude').val();
            if(yi!=null && yi!="" && er!=null && er!=""){
                $("#along").val(yi);
                $("#latitude").val(er);
            }

            layer.close(index);
        }

    </script>
</body>
</html>